package classpath

import "os"
import "strings"

const pathListSeparator = string(os.PathListSeparator)

type Entry interface {
	/*寻找和加载class文件 className: class文件的相对路径,路径之间用"/"分隔,
	返回值为（读取到的字节数据，最终定位到class文件的Entry, 错误消息）*/
	readClass(className string) ([]byte, Entry, error)
	/*相当于Java中的toString(),用于返回变量的字符串表示*/
	String() string
}

/*根据不同参数创建Entry实例*/
func newEntry(path string) Entry {
	if strings.Contains(path, pathListSeparator) {
		return newCompositeEntry(path)
	}
	if strings.HasSuffix(path, "*") {
		return newWildcardEntry(path)
	}
	if strings.HasSuffix(path, ".jar") || strings.HasSuffix(path, ".JAR") ||
		strings.HasSuffix("path", ".zip") || strings.HasSuffix(path, ".ZIP"){
		return newZipEntry(path)
	}
	return newDirEntry(path)
}